using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OF.Utility.Logging
{
    /// <summary>
    /// 原生log4net
    /// </summary>
   public class Log4netLog
    {
        /// <summary>
        /// 行为日志
        /// </summary>
        /// <param name="accessInfo"></param>
        public static void Info(ActionLog accessInfo)
        {
            ILog logger = LogManager.GetLogger("ActionLogAdoAppenderLogger");
            logger.Info(accessInfo);
        }

        /// <summary>
        /// 错误日志日志
        /// </summary>
        /// <param name="errorLog"></param>
        public static void Error(ErrorLog errorLog)
        {
            ILog logger = LogManager.GetLogger("ErrorLogAdoNetAppenderLogger");
            logger.Error(errorLog);
        }


        /// <summary>
        /// 文件日志
        /// </summary>
        /// <param name="message"></param>
        public static void Debug(string message)
        {
            ILog logger = LogManager.GetLogger("DebugLogTxtAppenderLogger");
            logger.Debug(message);
        }

        /// <summary>
        /// 错误日志日志
        /// </summary>
        /// <param name="ex"></param>
        public static void Error(Exception ex)
        {
            ILog logger = LogManager.GetLogger("ErrorLogAdoNetAppenderLogger");
            ErrorLog message = new ErrorLog();
            message.Platform = 1;
            message.CreatedDate = DateTime.Now;
            message.ErrorSource = ex.Source;
            message.ErrorTrace = ex.StackTrace;
            message.ErrorMessage = ex.Message;
            logger.Error(message);
        }
    }
}
